﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AzureDriveCore;

namespace AzureDriveUI
{
	public static class DriveServiceManager
	{
		public static bool StartService(DriveConfiguration driveConfiguration)
		{
			if (Environment.GetLogicalDrives().Any(item => item.ToUpper().StartsWith(driveConfiguration.DriveLetter[0].ToString())))
			{
				Console.WriteLine("The drive you selected is already in use.");

				return false;
			}

			VirtualDriveService.Start(driveConfiguration.DriveLetter,
				driveConfiguration.VolumeLabel, driveConfiguration.ConnectionString);

			return true;
		}

		public static bool StopService(string driveLetter)
		{
			return VirtualDriveService.Stop(driveLetter);
		}
	}
}
